home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 December / Chip Aralık 2001.iso / prog / share / text2pdf / setup.exe / txt2pdf.pl < prev    next >
Encoding:
Perl Script  |  2001-09-20  |  36.7 KB  |  1,107 lines

  1. #!/usr/bin/perl
  2. # Require Perl5
  3. #
  4. # txt2pdf -- Text to PDF
  5. #
  6. # by SANFACE Software <sanface@sanface.com> 18 September 2001
  7. #
  8. # txt2pdf 5.x is shareware: its cost is $99. Try it for 30 days.
  9. # If you decide to continue using it, register NOW via a SECURE SERVER at
  10. # http://www.regsoft.net/purchase.php3?productid=6347
  11. # or contact SANFACE Software sanface@sanface.com
  12. #
  13. # This is version 5.2
  14. #
  15. use strict;
  16. use Getopt::Long;
  17. use File::Basename;
  18. use File::Find;
  19. use File::DosGlob 'glob';
  20.  
  21. my $version="5.2";
  22. my $fpos=0;
  23. my $producer="txt2pdf";
  24. my $pageNO;
  25. my $lineNO;
  26. # Default paper is Letter size
  27. my $pageHeight=792;
  28. my $pageWidth=612;
  29. my @location;
  30. my @pageObj;
  31. my $lines=0; my $bflines=0;
  32. my $buf="";
  33. my $input=""; my $output=""; my $saveinput;
  34. my $elem="";
  35. my $configure="txt2pdf.cfg";
  36. my $help=0; my $default=0; my $verbose=0; my $Version; my $border=0; my $paper=""; my $landscape=0;
  37. my $npage=0; my $stdin=0;
  38. my $transition=""; my $motion=""; my $direction=0; my $dimension=""; my $rotate=0;
  39. my $bgdesign=""; my $fgdesign=""; my $epdi=0; my $epdn=0; my @epd;
  40. my (@color,@fontmark);
  41. my $colori=0; my $fontmarki=0;
  42. my $obj=0;
  43. my $Tpages=0; my $resources=0; my $root=0; my $info=0;
  44. my $BF; my $EF;
  45. my @annots; my $LLx=48;
  46. my $title="";
  47. my $counter;
  48. my $recursive=""; my $match="";
  49. my $line; my $page;
  50. my $companyname="SANFACE Software";
  51. my $pdfdir=""; my $txtdir=""; my $newoutput; my $newinput;
  52. my $txt2pdfHome="http://www.sanface.com/$producer.html";
  53. my $Unregistered="Generated by unregistered $producer v.$version \251 $companyname 2001\nAvailable at $txt2pdfHome \n";
  54. my $SANFACEmail="mailto:sanface\@sanface.com";
  55. my $SECURESERVER="http://www.regsoft.net/purchase.php3?productid=6347";
  56. my $font; my $times = 0; my $timef = 0; my $loop=1;
  57.  
  58. $configure = $ENV{'TXT2PDFCFG'} if (! -e "$configure");
  59.  
  60. &GetOptions("configure=s"  => \$configure,
  61.             "help"         => \$help,
  62.             "default"      => \$default,
  63.             "landscape"    => \$landscape,
  64.             "paper=s"      => \$paper,
  65.             "npage"        => \$npage,
  66.             "recursive=s"  => \$recursive,
  67.             "match=s"      => \$match,
  68.             "border"       => \$border,
  69.             "pdfdir=s"     => \$pdfdir,
  70.             "txtdir=s"     => \$txtdir,
  71.             ""             => \$stdin,
  72.             "current"      => \$Version,
  73.             "verbose"      => \$verbose) || printusage() ;
  74. my @elem=("tmpdir","author","creator","keywords","subject","title","landscape",
  75.           "paper","font","lines","tab","pointSize","vertSpace","transition",
  76.           "npage","colour","fontmark","beginfile","endfile","border","bgdesign","fgdesign",
  77.           "pagemode","pagelayout","rotate","typeencoding","withextension",
  78.           "sleep","pdfdir","txtdir");
  79. my %option=(tmpdir             => './',
  80.             author             => '',
  81.             creator            => '',
  82.             keywords           => '',
  83.             subject            => '',
  84.             title              => '',
  85.             landscape          => '0',
  86.             paper              => 'letter',
  87.             font               => 'Courier',
  88.             npage              => '0',
  89.             lines              => '',
  90.             pointSize          => '10',
  91.             vertSpace          => '12',
  92.             transition         => '',
  93.             tab                => '8',
  94.             colour             => '',
  95.             fontmark           => '',
  96.             beginfile          => '',
  97.             endfile            => '',
  98.             border             => '0',
  99.             bgdesign           => '',
  100.             fgdesign           => '',
  101.             pagemode           => '',
  102.             pagelayout         => '',
  103.             typeencoding       => 'default',
  104.             rotate             => '0',
  105.             withextension      => '0',
  106.             sleep              => '0',
  107.             pdfdir             => '',
  108.             txtdir             => '');
  109.  
  110. if($Version) {print "$producer $version\n";exit;}
  111. $help and printusage();
  112. $default and defaultparams();
  113. my $tmpelem; my $var;
  114. if (-e $configure) {
  115.   open (CNF, "$configure");
  116.   while (<CNF>) {
  117.     s/\t/ /g;        #replace tabs by space
  118.     next if /^ *\#/; #ignore comment lines
  119.     next if /^ *$/;  #ignore empty lines
  120.     foreach $elem (@elem) {
  121.       if (/ *$elem *: *(.*)/i) {
  122.         $tmpelem=$1;
  123.         if ($tmpelem=~/#!ENV#(.*)#!\/ENV#/) {
  124.           $var=$ENV{$1};
  125.           $tmpelem=~s/#!ENV#(.*)#!\/ENV#/$var/;
  126.           }
  127.         $option{$elem}=$tmpelem;
  128.         }
  129.       }
  130.     }
  131.   close(CNF);
  132.   } else {
  133.   &Warning("to set your txt2pdf configuration file you can use:\ntxt2pdf.cfg or -configure your_txt2pdf.cfg or TXT2PDFCFG\nElse the program will use the default parameters\n-default to see the default parameters\n")
  134.   }
  135. $paper and $option{'paper'}=$paper;
  136. $landscape and $option{'landscape'}=$landscape;
  137. $npage and $option{'npage'}=$npage;
  138. $border and $option{'border'}=$border;
  139. $pdfdir and $option{'pdfdir'}=$pdfdir;
  140. $txtdir and $option{'txtdir'}=$txtdir;
  141.  
  142. print <<FEE;
  143.  
  144. This is an UNREGISTERED version of $producer.
  145. Registration fee is \$99.
  146. Register NOW via a SECURE SERVER at
  147. $SECURESERVER
  148. or contact $companyname $SANFACEmail
  149.  
  150.  
  151. FEE
  152.  
  153. if ($stdin) {push @ARGV,"-";}
  154. if (uc($option{'paper'}) eq "A3")           {$pageWidth=842;  $pageHeight=1190;}
  155. elsif (uc($option{'paper'}) eq "A4")        {$pageWidth=595;  $pageHeight=842; }
  156. elsif (uc($option{'paper'}) eq "A5")        {$pageWidth=421;  $pageHeight=595; }
  157. elsif (uc($option{'paper'}) eq "TABLOID")   {$pageWidth=792;  $pageHeight=1224;}
  158. elsif (uc($option{'paper'}) eq "LEDGER")    {$pageWidth=1224; $pageHeight=792; }
  159. elsif (uc($option{'paper'}) eq "LEGAL")     {$pageWidth=612;  $pageHeight=1008;}
  160. elsif (uc($option{'paper'}) eq "STATEMENT") {$pageWidth=396;  $pageHeight=612; }
  161. elsif (uc($option{'paper'}) eq "EXECUTIVE") {$pageWidth=540;  $pageHeight=720; }
  162. elsif ($option{'paper'}=~/(\d+)x(\d+)/) {
  163.    if ($1<72) {$pageWidth=72}  else {$pageWidth=$1}
  164.    if ($2<72) {$pageHeight=72} else {$pageHeight=$2}
  165.    }
  166. else {
  167.   if (($option{'paper'}) && (uc($option{'paper'}) ne "LETTER"))
  168.     {&Warning("the set paper $option{'paper'} isn't supported\n$producer will use the default paper (letter)")}
  169.   }
  170.  
  171. if ($option{'landscape'}) {
  172.   my $tmp=$pageHeight;
  173.   $pageHeight=$pageWidth;
  174.   $pageWidth=$tmp;
  175.   }
  176. my $npagex=$pageWidth/2;
  177. my $npagey=20;
  178. my $typeencoding=$option{'typeencoding'};
  179. if (($typeencoding ne "MacRomanEncoding") && ($typeencoding ne "MacExpertEncoding") && ($typeencoding ne "WinAnsiEncoding") && ($typeencoding ne "default"))
  180.   {&Warning("the set encoding $typeencoding isn't MacRomanEncoding or MacExpertEncoding or WinAnsiEncoding or default\n$producer will use the default encoding (ISOLatin1Encoding)")}
  181.  
  182. if ($option{'transition'} eq "replace") {$transition=""}
  183. elsif ($option{'transition'} eq "dissolve") {$transition="Dissolve"}
  184. elsif ($option{'transition'}=~/box!(.*)!/)
  185.   {
  186.   $transition="Box";
  187.   if ($1 eq "I" || $1 eq "O") {$motion=$1}
  188.   else     {
  189.     &Warning("the set motion $1 with $transition transition isn't supported\n$producer will use the $transition I (Input) motion");
  190.     $motion="I";
  191.     }
  192.   }
  193. elsif ($option{'transition'}=~/glitter!(.*)!/)
  194.   {
  195.   $transition="Glitter";
  196.   if ($1 == 0 || $1 == 270 || $1 == 315) {$direction=$1}
  197.   else
  198.     {&Warning("the set direction $1 with $transition transition isn't supported\n$producer will use the $transition 0 direction")}
  199.   }
  200. elsif ($option{'transition'}=~/wipe!(.*)!/)
  201.   {
  202.   $transition="Wipe";
  203.   if ($1 == 0 || $1 == 90 || $1 == 180 || $1 == 270) {$direction=$1}
  204.   else
  205.     {&Warning("the set direction $1 with $transition transition isn't supported\n$producer will use the $transition 0 direction")}
  206.   }
  207. elsif ($option{'transition'}=~/blinds!(.*)!/)
  208.   {
  209.   $transition="Blinds";
  210.   if ($1 eq "H" || $1 eq "V") {$dimension=$1}
  211.   else     {
  212.     &Warning("the set dimension $1 with $transition transition isn't supported\n$producer will use the $transition H dimension");
  213.     $dimension="H";
  214.     }
  215.   }
  216. elsif ($option{'transition'}=~/split!(.*)!(.*)!/)
  217.   {
  218.   $transition="Split";
  219.   if ($1 eq "H" || $1 eq "V") {$dimension=$1}
  220.   else     {
  221.     &Warning("the set dimension $1 with $transition transition isn't supported\n$producer will use the $transition H dimension");
  222.     $dimension="H";
  223.     }
  224.   if ($2 eq "I" || $2 eq "O") {$motion=$2}
  225.   else     {
  226.     &Warning("the set motion $1 with $transition transition isn't supported\n$producer will use the $transition I (Input) motion");
  227.     $motion="I";
  228.     }
  229.   }
  230. else { 
  231.   if ($option{'transition'})
  232.     {
  233.     &Warning("the set transition $option{'transition'} isn't supported\n$producer will use the default transition (replace)");
  234.     $option{'transition'}="";
  235.     }
  236.   }
  237.  
  238.   if (($option{'pagemode'} ne "FullScreen") && ($option{'pagemode'} ne "")){
  239.     &Warning("the set page mode $option{'pagemode'} isn't supported\n$producer will use the default page mode (UseNone)");
  240.     $option{'pagemode'}="";
  241.     }
  242.  
  243.   if (($option{'pagelayout'} ne "OneColumn") && ($option{'pagelayout'} ne "TwoColumnRight") && ($option{'pagelayout'} ne "TwoColumnLeft") && ($option{'pagelayout'} ne "")) {
  244.     &Warning("the set page layout $option{'pagelayout'} isn't supported\n$producer will use the default page layout (SinglePage)");
  245.     $option{'pagelayout'}="";
  246.     }
  247.  
  248. if ($option{'lines'}) {$lines = $option{'lines'}}
  249. else {$lines = ($pageHeight - 72) / $option{'vertSpace'}}
  250. $lines = int $lines;
  251. if (($option{'font'} ne "Courier") && ($option{'font'} ne "Helvetica") && ($option{'font'} ne "Times")) {
  252.   &Warning("the set font $option{'font'} isn't Courier or Helvetica or Times\n$producer will use the default font (Courier)");
  253.   $option{'font'}="Courier";
  254.   }
  255. if (($option{'rotate'} == 0) || ($option{'rotate'} == 90) || ($option{'rotate'} == 180) || ($option{'rotate'} == 270))
  256.   {$rotate=$option{'rotate'}}
  257. else {
  258.    &Warning("the set rotate $option{'rotate'} isn't supported\n$producer will use the default rotate (0)");
  259.    $rotate=0;
  260.    }
  261. if ($option{'colour'})
  262.   {
  263.   open (COLOUR, "$option{'colour'}") ||
  264.      die "txt2pdf: couldn't open colour file $option{'colour'}\n";
  265.   while (<COLOUR>) {
  266.     if (/^(.*);(.*)$/) {
  267.       $color[$colori*4]=$1;
  268.       ($color[$colori*4+1],$color[$colori*4+2],$color[$colori*4+3])=split(/:/,$2);
  269. #      if($color[$colori*4+1] > 1.0 || $color[$colori*4+2] > 1.0 || $color[$colori*4+3] > 1.0) {
  270. #        # Use 255 based color scheme
  271. #        my($i);
  272. #        for($i=1;$i<4;$i++){$color[$colori*4+$i] = sprintf("%4f",$color[$colori*4+$i]/255.0)}
  273. #        }
  274.       $colori++;
  275.       }
  276.     }
  277.   close(COLOUR);
  278.   }
  279. if ($option{'fontmark'})
  280.   {
  281.   open (FONTMARK, "$option{'fontmark'}") ||
  282.      die "txt2pdf: couldn't open fontmark file $option{'fontmark'}\n";
  283.   while (<FONTMARK>) {
  284.     if (/^(.*);(.*)$/) {
  285.       $fontmark[$fontmarki*2]=$1;
  286.       $fontmark[$fontmarki*2+1]=$2;
  287.       if    ($fontmark[$fontmarki*2+1] eq "bold") {$fontmark[$fontmarki*2+1]="/F3"}
  288.       elsif ($fontmark[$fontmarki*2+1] eq "italic") {$fontmark[$fontmarki*2+1]="/F2"}
  289.       elsif ($fontmark[$fontmarki*2+1] eq "bolditalic") {$fontmark[$fontmarki*2+1]="/F4"}
  290.       else {$fontmark[$fontmarki*2+1]="/F1"}
  291.       $fontmarki++;
  292.       }
  293.     }
  294.   close(FONTMARK);
  295.   }
  296. if ($option{'bgdesign'})
  297.   {
  298.   open (BGDESIGN, "$option{'bgdesign'}") ||
  299.      die "$producer: couldn't open background design file $option{'bgdesign'}\n";
  300.   while (<BGDESIGN>) {
  301.     s/\015$//;
  302.     if (/^#!epd#(.*);(.*);(.*);(.*);(.*);(.*);(.*)#!\/epd#$/) {
  303.       $epd[$epdi*9]=$1;
  304.       $epd[$epdi*9+2]=0;
  305.       $epd[$epdi*9+3]=$2;
  306.       $epd[$epdi*9+4]=$3;
  307.       $epd[$epdi*9+5]=$4;
  308.       $epd[$epdi*9+6]=$5;
  309.       $epd[$epdi*9+7]=$6;
  310.       $epd[$epdi*9+8]=$7;
  311.       $epdi++;
  312.       next;
  313.       }
  314.     $bgdesign.=$_;
  315.     }
  316.   close(BGDESIGN);
  317.   }
  318. if ($option{'fgdesign'})
  319.   {
  320.   open (FGDESIGN, "$option{'fgdesign'}") ||
  321.      die "$producer: couldn't open foreground design file $option{'fgdesign'}\n";
  322.   while (<FGDESIGN>) {s/\015$//;$fgdesign.=$_;}
  323.   close(FGDESIGN);
  324.   }
  325.  
  326. sub wanted {
  327.   if ($File::Find::name=~/$match/) {
  328.     push @ARGV,$File::Find::name;
  329.     }
  330.   }
  331.  
  332. if ($match && !$recursive) {
  333.    print "You can use -match option only with -recursive option\n";
  334.    exit;
  335.    }
  336.  
  337. SLEEP:
  338. if ($recursive) {
  339.   if($loop == 1) {
  340.     $match=~s/\./\\./g;
  341.     $match=~s/\*/.*/g;
  342.     $match=~s/\?/./g;
  343.     $match=~s/$/\$/;
  344.     }
  345.   @ARGV=();
  346.   find (\&wanted,"$recursive");
  347.   }
  348.  
  349. my $URy=$pageHeight - 42;
  350. my $tmpfile = $option{'tmpdir'} . "txt2pdf$$";
  351.  
  352.   if ($option{'beginfile'}) {
  353.     open (BEGINFILE,$option{'beginfile'}) ||
  354.       die qq!$producer: couldn't open input file $option{'beginfile'}\n!;
  355.     binmode BEGINFILE;
  356.     while(<BEGINFILE>) {
  357.       s/\r?\n$/\n/;
  358.       s/\r/\n/g;
  359.       $bflines++;
  360.       $_=&TAB($_);
  361.       $BF.=$_;
  362.       }
  363.     close(BEGINFILE);
  364.     }
  365.   if ($option{'endfile'}) {
  366.     open (ENDFILE,$option{'endfile'}) ||
  367.       die qq!$producer: couldn't open input file $option{'endfile'}\n!;
  368.     binmode ENDFILE;
  369.     while(<ENDFILE>) {
  370.       s/\r?\n$/\n/;
  371.       s/\r/\n/g;
  372.       $_=&TAB($_);
  373.       $EF.=$_;
  374.       }
  375.     close(ENDFILE);
  376.     }
  377.  
  378. if (@ARGV) {
  379.   my @files;
  380.   my $i;
  381.  
  382.   if ($^O =~ /^MSWin32$/i && !$recursive) {
  383.     foreach $i (@ARGV) {
  384.       if($i=~/\*|\?/) {push @files,glob($i)}
  385.       else {push @files,$i}
  386.       }
  387.     }
  388.   else {@files = @ARGV}
  389.   foreach $input (@files) {
  390.     $obj=0;
  391.     $pageNO=0;
  392.     $fpos=0;
  393.     @pageObj='';
  394.     $verbose and $times = time;
  395.     if(!$option{'title'}) {$title=basename($input,"")}
  396.     else {$title=$option{'title'}}
  397.     $verbose and print "Processing $input file\n";
  398.     if ($stdin) {open (OUT, ">-") || die "$producer: couldn't open standard output\n"}
  399.     else {
  400.       $output=$input;
  401.       $saveinput=$input;
  402.       my $out=basename($output,"");
  403.       if ($out=~/(.*)\..*/ and !$option{'withextension'}) {$out=~s/(.*)\..*/$1\.pdf/;}
  404.         else {$out.=".pdf";}
  405.       $output=dirname($output,"");
  406.   
  407.       if ($^O =~ /VMS/ ) {
  408. # On OpenVMS: Also don't add '/' if dir ends in ']' or ':'
  409. #    e.g. VMS filepecs look like
  410.         $output.="/" if ($output !~ /(\/|\\|]|:)$/ );
  411.       } elsif ($^O eq 'MacOS') {
  412.         $output.=":" if ($output !~ /:$/ ); # macs are a bit different...
  413.       } else {
  414. # concat '/' only if dir doesn't already end in a '/' or '\\'
  415.         $output.="/" if ($output !~ /(\/|\\)$/ );
  416.       }
  417.       $output.=$out;
  418.       open (OUT, ">$output") || die "$producer: couldn't open output file $output\n";
  419.     }
  420.     binmode OUT;
  421.     &ReorganizeFile($input);
  422.     &WriteLink($tmpfile);
  423.     &WriteHeader();
  424.     &WritePages($tmpfile);
  425.     &WriteRest();
  426.     close(OUT);
  427.  
  428.     # a simple user-interface enhancement
  429.     # make a MacOS double-clickable file
  430.     if ($^O eq 'MacOS') {MacPerl::SetFileInfo('CARO','PDF ', $output)}
  431.     $verbose and print "Writing $output file\n";
  432.     }
  433.     if ($^O =~ /VMS/ ) {
  434. # On OpenVMS, need While to delete all versions of tmpfile
  435.       while ( unlink($tmpfile) ) {};
  436.     } else {
  437.       unlink($tmpfile);
  438.     }
  439.   if($option{'txtdir'} ne "")
  440.     {
  441.     $newinput=$option{'txtdir'}.basename($saveinput);
  442.     rename $saveinput,$newinput;
  443.     $verbose and print "Moving $saveinput file in the $option{'txtdir'} directory\n";
  444.     }
  445.   if($option{'pdfdir'} ne "")
  446.     {
  447.     $newoutput=$option{'pdfdir'}.basename($output);
  448.     rename $output,$newoutput;
  449.     $verbose and print "Moving $output file in the $option{'pdfdir'} directory\n";
  450.     }
  451.   if ($verbose) {$timef = time; printf ("PDF generation time = %4.2f sec\n", $timef - $times );}
  452.   if($option{'sleep'}) {
  453.     sleep $option{'sleep'};
  454.     $loop++;
  455.     $verbose and print "\nLoop number $loop\n";
  456.     goto SLEEP;
  457.     }
  458.   } else {
  459.   print "$producer -help to read the online help\n";
  460.   if($option{'sleep'}) {
  461.     sleep $option{'sleep'};
  462.     $loop++;
  463.     $verbose and print "\nLoop number $loop\n";
  464.     goto SLEEP;
  465.     }
  466.   }
  467.  
  468. sub ReorganizeFile {
  469.   my $file=shift(@_);
  470.  
  471.   my $i;
  472.   my $temporary;
  473.   open (IN, "$file") || die "$producer: couldn't open input file $file\n";
  474.   open (TEMP, ">$tmpfile") || die "$producer: couldn't open temporary file $tmpfile\n";
  475.   binmode TEMP;
  476.   if($BF) {print TEMP "$BF"}
  477.   binmode IN;
  478.   while (<IN>) {
  479.     s/\r?\n$/\n/;
  480.     s/\r/\n/g;
  481.     $_ = &TAB($_);
  482.     print TEMP "$_";
  483.     }
  484.   if($EF) {print TEMP "$EF"}
  485.   print TEMP "\n";
  486.   print TEMP $Unregistered;
  487.   close(IN);
  488.   close(TEMP);
  489.   }
  490.  
  491. sub WriteLink {
  492.   my $file=shift(@_);
  493.  
  494.   # Start PDF
  495.   &pos("%PDF-1.2\n");
  496.   # It is recommended that the second line of a PDF file be a comment that
  497.   # contains at least four characters with codes 128 or greater
  498.   &pos("%Γπ╧╙\n");
  499.   $line=0;
  500.   $page=1;
  501.   open (IN, "$file") || die "$producer: couldn't open input file $file\n";
  502.   my $linktemp;
  503.   binmode IN;
  504.   while (<IN>) {
  505.     $line++;
  506.     $linktemp=$_;
  507.     while ($linktemp=~/(.*)((http|ftp|mailto|https|file|ldap|news):[^ \n)]+)( +|$|\))/i) {
  508.       $linktemp=$1;
  509.       &Link(length $1,length $2,$2,"url");
  510.       }
  511.     ##  14May99 - Modified to handle the mime: marker.  It's just a
  512.     ##            tweak of the original link test
  513.     while ($linktemp=~/(.*)(mime:[^ \n)]+)( +|$|\))/i) {
  514.       $linktemp=$1;
  515.       &Link(length $1,length $2,$2,"file");
  516.       }
  517.     if ($line == $lines) {
  518.         $line=0;
  519.         $page++;
  520.       }
  521.     }
  522.   close (IN);
  523.   }
  524.  
  525. sub WriteHeader {
  526.   my $sec=0; my $min=0; my $hour=0; my $mday=0; my $mon=0; my $year=0;
  527.   my $wday=0; my $yday=0; my $isdst=0; my $date="";
  528.   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  529.   ++$mon;                              # $mon is 0..11
  530.   $year += 1900;
  531.   my $gm = (gmtime(time))[2];
  532.   my $local = (localtime(time))[2];
  533.   my $diff = $local - $gm;
  534.   if ($diff <= -12) { $diff += 24 }
  535.   elsif ($diff > 12) { $diff -= 24 }
  536.   my $zone = $diff;
  537.   if ($zone =~ /-/) {$zone = sprintf "%.2d00", $zone}
  538.   else  {$zone = sprintf "+%.2d00", $zone}
  539.   $date=sprintf "D:$year%.2ld%.2ld%.2ld%.2ld%.2ld$zone",$mon,$mday,$hour,$min,$sec;
  540.   $location[++$obj]=$fpos;
  541.   $info=$obj;
  542.   &pos("$obj 0 obj\n");
  543.   &pos("<<\n");
  544.   $option{'author'} and &pos("/Author ($option{'author'})\n");
  545.   &pos("/CreationDate ($date)\n");
  546.   $option{'creator'} and &pos("/Creator ($option{'creator'})\n");
  547.   &pos("/Producer ($producer v$version \\251 $companyname 2001)\n");
  548.   &pos("/Title ($title)\n");
  549.   $option{'subject'} and &pos("/Subject ($option{'subject'})\n");
  550.   $option{'keywords'} and &pos("/Keywords ($option{'keywords'})\n");
  551.   &pos(">>\n");
  552.   &pos("endobj\n");
  553.   $root=++$obj;
  554.   $Tpages=++$obj;
  555.   $epdn=($#epd+1)/9;
  556.   my $i=0;
  557.   my $epdbox="";
  558.   for (1..$epdn) {
  559.     open (EPD, $epd[$i*9]) || die "$producer: couldn't open image $epd[$i*9]\n";
  560.     binmode EPD;
  561.     while (<EPD>) {
  562.       s/\r?\n$/\n/;
  563.       s/\r/\n/g;
  564.       /BBox\((.*)\)/ and $epdbox=join(' ',split(/,/,$1));
  565.       }
  566.     $location[++$obj]=$fpos;
  567.     $epd[$i*9+2]=$obj;
  568.     &pos("$obj 0 obj\n");
  569.     &pos("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1 /Name /Fm$i\n/Matrix [ 1 0 0 1 0 0 ]\n/BBox [ $epdbox ]\n");
  570.     $buf=sprintf "/Length %d 0 R ",$obj+1; &pos($buf);
  571.     &pos("/Resources << >> >>\n");
  572.     &pos("stream\n");
  573.     my $streamStart=$fpos;
  574.     open (EPD, $epd[$i*9]) || die "$producer: couldn't open image $epd[$i*9]\n";
  575.     binmode EPD;
  576.     while (<EPD>) {
  577.       / *%(.*)/ and next;
  578.       &pos("$_");
  579.       }
  580.     close(EPD);
  581.     my $streamEnd=$fpos;
  582.     &pos("\nendstream\n");
  583.     &pos("endobj\n");
  584.     $location[++$obj]=$fpos;
  585.     &pos("$obj 0 obj\n");
  586.     $buf=sprintf "%d\n",$streamEnd-$streamStart; &pos($buf);
  587.     &pos("endobj\n");
  588.     $i++;
  589.     }
  590.   my $encoding=$obj+5;
  591.   $resources=$obj+6;
  592.   $location[++$obj]=$fpos;
  593.   &pos("$obj 0 obj\n");
  594.   &pos("<<\n");
  595.   &pos("/Type /Font\n");
  596.   &pos("/Subtype /Type1\n");
  597.   &pos("/Name /F1\n");
  598.   &pos("/Encoding $encoding 0 R\n");
  599.   if ($option{'font'} eq "Times") {&pos("/BaseFont /$option{'font'}-Roman\n")}
  600.   else {&pos("/BaseFont /$option{'font'}\n")}
  601.   &pos(">>\n");
  602.   &pos("endobj\n");
  603.   $location[++$obj]=$fpos;
  604.   &pos("$obj 0 obj\n");
  605.   &pos("<<\n");
  606.   &pos("/Type /Font\n");
  607.   &pos("/Subtype /Type1\n");
  608.   &pos("/Name /F2\n");
  609.   &pos("/Encoding $encoding 0 R\n");
  610.   if ($option{'font'} eq "Times") {&pos("/BaseFont /$option{'font'}-Italic\n")}
  611.   else {&pos("/BaseFont /$option{'font'}-Oblique\n")}
  612.   &pos(">>\n");
  613.   &pos("endobj\n");
  614.   $location[++$obj]=$fpos;
  615.   &pos("$obj 0 obj\n");
  616.   &pos("<<\n");
  617.   &pos("/Type /Font\n");
  618.   &pos("/Subtype /Type1\n");
  619.   &pos("/Name /F3\n");
  620.   &pos("/Encoding $encoding 0 R\n");
  621.   &pos("/BaseFont /$option{'font'}-Bold\n");
  622.   &pos(">>\n");
  623.   &pos("endobj\n");
  624.   $location[++$obj]=$fpos;
  625.   &pos("$obj 0 obj\n");
  626.   &pos("<<\n");
  627.   &pos("/Type /Font\n");
  628.   &pos("/Subtype /Type1\n");
  629.   &pos("/Name /F4\n");
  630.   &pos("/Encoding $encoding 0 R\n");
  631.   if ($option{'font'} eq "Times") {&pos("/BaseFont /$option{'font'}-BoldItalic\n")}
  632.   else {&pos("/BaseFont /$option{'font'}-BoldOblique\n")}
  633.   &pos(">>\n");
  634.   &pos("endobj\n");
  635. # ISOLatin1Encoding
  636.   $location[++$obj]=$fpos;
  637.   &pos("$obj 0 obj\n");
  638.   &pos("<<\n");
  639.   &pos("/Type /Encoding\n");
  640.   if ($typeencoding eq "WinAnsiEncoding") {&pos("/BaseEncoding /WinAnsiEncoding\n")}
  641.   elsif ($typeencoding eq "MacRomanEncoding") {&pos("/BaseEncoding /MacRomanEncoding\n")}
  642.   elsif ($typeencoding eq "MacExpertEncoding") {&pos("/BaseEncoding /MacExpertEncoding\n")}
  643.   else {
  644.     &pos("/Differences [ 0 /.notdef /.notdef /.notdef /.notdef\n");
  645.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  646.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  647.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  648.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  649.     &pos("/.notdef /.notdef /.notdef /.notdef /space /exclam\n");
  650.     &pos("/quotedbl /numbersign /dollar /percent /ampersand\n");
  651.     &pos("/quoteright /parenleft /parenright /asterisk /plus /comma\n");
  652.     &pos("/hyphen /period /slash /zero /one /two /three /four /five\n");
  653.     &pos("/six /seven /eight /nine /colon /semicolon /less /equal\n");
  654.     &pos("/greater /question /at /A /B /C /D /E /F /G /H /I /J /K /L\n");
  655.     &pos("/M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft\n");
  656.     &pos("/backslash /bracketright /asciicircum /underscore\n");
  657.     &pos("/quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p\n");
  658.     &pos("/q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright\n");
  659.     &pos("/asciitilde /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  660.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  661.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  662.     &pos("/dotlessi /grave /acute /circumflex /tilde /macron /breve\n");
  663.     &pos("/dotaccent /dieresis /.notdef /ring /cedilla /.notdef\n");
  664.     &pos("/hungarumlaut /ogonek /caron /space /exclamdown /cent\n");
  665.     &pos("/sterling /currency /yen /brokenbar /section /dieresis\n");
  666.     &pos("/copyright /ordfeminine /guillemotleft /logicalnot /hyphen\n");
  667.     &pos("/registered /macron /degree /plusminus /twosuperior\n");
  668.     &pos("/threesuperior /acute /mu /paragraph /periodcentered\n");
  669.     &pos("/cedilla /onesuperior /ordmasculine /guillemotright\n");
  670.     &pos("/onequarter /onehalf /threequarters /questiondown /Agrave\n");
  671.     &pos("/Aacute /Acircumflex /Atilde /Adieresis /Aring /AE\n");
  672.     &pos("/Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave\n");
  673.     &pos("/Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve\n");
  674.     &pos("/Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n");
  675.     &pos("/Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn\n");
  676.     &pos("/germandbls /agrave /aacute /acircumflex /atilde /adieresis\n");
  677.     &pos("/aring /ae /ccedilla /egrave /eacute /ecircumflex\n");
  678.     &pos("/edieresis /igrave /iacute /icircumflex /idieresis /eth\n");
  679.     &pos("/ntilde /ograve /oacute /ocircumflex /otilde /odieresis\n");
  680.     &pos("/divide /oslash /ugrave /uacute /ucircumflex /udieresis\n");
  681.     &pos("/yacute /thorn /ydieresis ]\n");
  682.     }
  683.   &pos(">>\n");
  684.   &pos("endobj\n");
  685.   $location[++$obj]=$fpos;
  686.   &pos("$obj 0 obj\n");
  687.   &pos("<<\n");
  688.   $buf=sprintf "  /Font << /F1 %d 0 R /F2 %d 0 R /F3 %d 0 R /F4 %d 0 R >>\n",
  689.        $obj-5, $obj-4, $obj-3, $obj-2;
  690.   &pos($buf);
  691.   &pos("  /ProcSet [ /PDF /Text ]\n");
  692.   &pos("  /XObject << ");
  693.   $i=0;
  694.   for (1..$epdn) {
  695.     &pos("/Fm$i $epd[$i*9+2] 0 R ");
  696.     $i++;
  697.     }
  698.   &pos(">>\n");
  699.   &pos(">>\n");
  700.   &pos("endobj\n");
  701.   }
  702.  
  703. sub WritePages {
  704.   my $file=shift(@_);
  705.  
  706.   my $columns="";
  707.   my $pageNO2=1;
  708.   my $temp;
  709.   my $i;
  710.   my $parseword;
  711.   my $thistest;
  712.   my $testfont;
  713.   my $converted=0;
  714.  
  715.   open (IN, "$file") || die "$producer: couldn't open input file $file\n";
  716.   my $beginstream = &StartPage();
  717.   $lineNO=-1;
  718.   binmode IN;
  719.   while (<IN>) {
  720.     $temp=$_;
  721.     $lineNO++;
  722.     if ($lineNO eq $lines) {
  723.       if ($option{'npage'}) {
  724.         &pos("/F2 $option{'pointSize'} Tf\n");
  725.         &pos("1 0 0 1 $npagex $npagey Tm\n($pageNO) Tj\n");
  726.         &pos("/F1 $option{'pointSize'} Tf\n");
  727.         }
  728.       &EndPage($beginstream);
  729.       $beginstream = &StartPage();
  730.       }
  731.     chop($temp);
  732.     $temp=~s/\\/\\\\/g;
  733.     $temp=~s/\(/\\(/g;
  734.     $temp=~s/\)/\\)/g;
  735.     &pos("T* (");
  736.     my $color=($#color+1)/4;
  737.     my $il=0;
  738.     for (1..$color) {
  739.       $temp=~s/($color[$il*4])/) Tj\n $color[$il*4+1] $color[$il*4+2] $color[$il*4+3] rg\n ($1) Tj\n 0 0 0 rg\n (/g;
  740.       $il++;
  741.       }
  742.     my $fontmark=($#fontmark+1)/2;
  743.     $il=0;
  744.     for (1..$fontmark) {
  745.       $temp=~s/($fontmark[$il*2])/) Tj\n $fontmark[$il*2+1] $option{'pointSize'} Tf\n ($1) Tj\n \/F1 $option{'pointSize'} Tf\n (/g;
  746.       $il++;
  747.       }
  748. #    if ($temp=~/((http|ftp|mailto|mime|https|file|ldap|news):[^ \n]*) /i)
  749. #      {
  750. #      $substring=") Tj\n 0 0 1 rg\n ($1) Tj\n 0 0 0 rg (";
  751. #      $temp=~s/$1/$substring/g;
  752. #      }
  753.     &pos("$temp");                                               
  754.     &pos(") Tj\n");
  755.     }
  756.   close(IN);
  757.   if ($option{'npage'}) {
  758.     &pos("/F2 $option{'pointSize'} Tf\n");
  759.     &pos("1 0 0 1 $npagex $npagey Tm\n($pageNO) Tj\n");
  760.     &pos("/F1 $option{'pointSize'} Tf\n");
  761.     }
  762.   &EndPage($beginstream);
  763.   }
  764.  
  765. # End PDF
  766. sub WriteRest {
  767.   my $i;
  768.   $location[$root]=$fpos;
  769.   &pos("$root 0 obj\n");
  770.   &pos("<<\n");
  771.   &pos("/Type /Catalog\n");
  772.   &pos("/Pages $Tpages 0 R\n");
  773. #  &pos("/OpenAction << /Dest [ 1 /XYZ null null 5 ] >>\n");
  774.   if ($option{'pagemode'}) {&pos("/PageMode /$option{'pagemode'}\n")};
  775.   if ($option{'pagelayout'}) {&pos("/PageLayout /$option{'pagelayout'}\n")};
  776.   &pos(">>\n");
  777.   &pos("endobj\n");
  778.   $location[$Tpages]=$fpos;
  779.   &pos("$Tpages 0 obj\n");
  780.   &pos("<<\n");
  781.   &pos("/Type /Pages\n");
  782.   &pos("/Count $pageNO\n");
  783.   &pos("/MediaBox [ 0 0 $pageWidth $pageHeight ]\n");
  784.   &pos("/Kids [ ");
  785.   for ($i=1; $i<=$pageNO;$i++) {&pos("$pageObj[$i] 0 R ");}
  786.   &pos("]\n");
  787.   &pos(">>\n");
  788.   &pos("endobj\n");
  789.   my $xfer = $fpos;
  790.   &pos("xref\n");
  791.   $buf=sprintf "0 %d\n",$obj+1; &pos($buf);
  792.   &pos("0000000000 65535 f \n");
  793.   my $num="";
  794.   for ($i=1;$i<=$obj;$i++) {
  795.     $buf=sprintf "%.10ld 00000 n \n",$location[$i];
  796.     &pos($buf);
  797.     }
  798.   &pos("trailer\n");
  799.   &pos("<<\n");
  800.   $buf=sprintf "/Size %d\n",$obj+1; &pos($buf);
  801.   &pos("/Root $root 0 R\n");
  802.   &pos("/Info $info 0 R\n");
  803.   &pos(">>\n");
  804.   &pos("startxref\n");
  805.   &pos("$xfer\n");
  806.   &pos("%%EOF\n");
  807.   }
  808.  
  809. sub StartPage {
  810.  
  811.   $location[++$obj]=$fpos;
  812.   $pageObj[++$pageNO]=$obj;
  813.   &pos("$obj 0 obj\n");
  814.   &pos("<<\n");
  815.   &pos("/Type /Page\n");
  816.   &pos("/Parent $Tpages 0 R\n");
  817.   &pos("/Resources $resources 0 R\n");
  818.   $buf=sprintf "/Contents %d 0 R\n",++$obj; &pos($buf);
  819.   &pos("/Rotate $rotate\n");
  820.   if ($transition eq "Dissolve") {&pos("/Trans << /Type /Trans /S /$transition >>\n")}
  821.   if ($transition eq "Box") {&pos("/Trans << /Type /Trans /S /$transition /M /$motion >>\n")}
  822.   if ($transition eq "Glitter") {&pos("/Trans << /Type /Trans /S /$transition /Di $direction >>\n")}
  823.   if ($transition eq "Wipe") {&pos("/Trans << /Type /Trans /S /$transition /Di $direction >>\n")}
  824.   if ($transition eq "Blinds") {&pos("/Trans << /Type /Trans /S /$transition /Dm /$dimension >>\n")}
  825.   if ($transition eq "Split") {&pos("/Trans << /Type /Trans /S /$transition /Dm /$dimension /M /$motion >>\n")}
  826.   $annots[$pageNO] and &pos("/Annots [ $annots[$pageNO]]\n");
  827.   &pos(">>\n");
  828.   &pos("endobj\n");
  829.   $location[$obj]=$fpos;
  830.   &pos("$obj 0 obj\n");
  831.   &pos("<<\n");
  832.   $buf=sprintf "/Length %d 0 R\n",$obj+1; &pos($buf);
  833.   &pos(">>\n");
  834.   &pos("stream\n");
  835.   my $strmPos=$fpos;
  836.   my $i=0;
  837.   if ($epdn) {
  838.     $i=0;
  839.     for (1..$epdn) {
  840.       &pos("q $epd[$i*9+3] $epd[$i*9+4] $epd[$i*9+5] $epd[$i*9+6] $epd[$i*9+7] $epd[$i*9+8] cm /Fm$i Do Q\n");
  841.       $i++;
  842.       }
  843.     }
  844.   my $default=15;
  845.   my $Width=$pageWidth - $default;
  846.   my $Height=$pageHeight - $default;
  847.   if ($option{'border'}) {
  848.     &pos("2 w\n");
  849.     &pos("1 1 1 rg\n");
  850.     &pos("$default $default m\n$Width $default l\n");
  851.     &pos("$Width $default m\n$Width $Height l\n");
  852.     &pos("$Width $Height m\n$default $Height l\n");
  853.     &pos("$default $Height m\n$default $default l\n");
  854.     &pos("B*\n");
  855.     }
  856.   if ($bgdesign) {&pos("$bgdesign")}
  857.   &pos("BT\n");
  858.   &pos("/F1 $option{'pointSize'} Tf\n");
  859.   $buf=sprintf "1 0 0 1 50 %d Tm\n",$pageHeight-40; &pos($buf);
  860.   &pos("$option{'vertSpace'} TL\n");
  861.   return ($strmPos);
  862.   }
  863.  
  864. sub EndPage {
  865.   my $streamStart=shift(@_);
  866.   my $streamEnd=0;
  867.   &pos("ET\n");
  868.   if ($fgdesign) {&pos("$fgdesign")}
  869.   $streamEnd=$fpos;
  870.   &pos("endstream\n");
  871.   &pos("endobj\n");
  872.   $location[++$obj]=$fpos;
  873.   &pos("$obj 0 obj\n");
  874.   $buf=sprintf "%d\n",$streamEnd-$streamStart; &pos($buf);
  875.   &pos("endobj\n");
  876.   $lineNO=0;
  877.   }
  878.  
  879. sub Link {
  880.   my $linkbegin=shift(@_);
  881.   my $linkend=shift(@_);
  882.   my $link=shift(@_);
  883.   my $type=shift(@_);
  884.  
  885.   my $tmpline=$line;
  886.   $location[++$obj]=$fpos;
  887.   &pos("$obj 0 obj\n");
  888.   &pos("<<\n");
  889.   &pos("/A <<\n");
  890.   if ($type eq "url") {
  891.     &pos("/S /URI\n");
  892.     &pos("/URI ($link)\n");
  893.     } else {
  894.     &pos("/S /Launch\n");
  895.     my $slink = substr($link, 5); ## Pull the file: from the front
  896.     &pos("/F ($slink)\n");
  897.     }
  898.   &pos(">>\n");
  899.   &pos("/Type /Annot\n");
  900.   &pos("/Subtype /Link\n");
  901. # LLx LLy URx URy
  902.   if ($option{'font'} eq "Courier") {
  903.     $buf=sprintf "/Rect [%d %d %d %d]\n",
  904. $LLx+$linkbegin*$option{'pointSize'}*0.6,
  905. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-$tmpline*$option{'pointSize'},
  906. $LLx+($linkbegin+$linkend)*$option{'pointSize'}*0.6+$option{'pointSize'}*0.3,
  907. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-($tmpline-1)*$option{'pointSize'};
  908.     }
  909.   elsif ($option{'font'} eq "Helvetica") {
  910.     $buf=sprintf "/Rect [%d %d %d %d]\n",
  911. $LLx+$linkbegin*($option{'pointSize'}/2-1),
  912. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-$tmpline*$option{'pointSize'},
  913. $LLx+$linkbegin*($option{'pointSize'}/2-1)+($linkend+1)*($option{'pointSize'}/2-1),
  914. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-($tmpline-1)*$option{'pointSize'};
  915.     }
  916.   else {
  917.     $buf=sprintf "/Rect [%d %d %d %d]\n",
  918. $LLx+$linkbegin*($option{'pointSize'}/2-1),
  919. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-$tmpline*$option{'pointSize'},
  920. $LLx+$linkbegin*($option{'pointSize'}/2-1)+($linkend+1)*($option{'pointSize'}/2-1),
  921. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-($tmpline-1)*$option{'pointSize'};
  922.     }
  923.   &pos($buf);
  924. # Bordo azzurro
  925. #  &pos("/C [0 0 1]\n");
  926. # Rettangolo invisibile
  927.   &pos("/Border [0 0 0]\n");
  928.   &pos("/H /I\n");
  929.   &pos(">>\n");
  930.   &pos("endobj\n");
  931.   $annots[$page].="$obj 0 R ";
  932.   }
  933.  
  934. sub TAB {
  935.   my $line=shift(@_);
  936.   while($line=~/([^\t]*)\t/) {
  937.     my $spaces="";
  938.     my $spaceNO=$option{'tab'}-(length $1)%$option{'tab'};
  939.     for(1..$spaceNO) {$spaces.=" ";}
  940.     $line=~s/([^\t]*)\t/$1$spaces/;
  941.     }
  942.   return($line);
  943.   }
  944.  
  945. sub pos {
  946.   my $string = shift(@_);
  947.   $fpos+=length $string;
  948.   print OUT "$string";
  949.   }
  950.  
  951. sub Warning {
  952.   my $string = shift(@_);
  953.   print <<WARNING;
  954. Warning: $string
  955.  
  956. WARNING
  957.   }
  958.  
  959. sub printusage {
  960.     print <<USAGEDESC;
  961.  
  962. usage:
  963.         $producer [-options ...] list
  964.  
  965. where options include:
  966.     -help                        print out this message
  967.     -default                     print out the default parameters
  968.     -configure file              default $producer.cfg
  969.     -landscape
  970.     -paper format                default letter, valid formats: A3 (or a3),
  971.                                  A4 (or a4), A5 (or a5), widthxheight
  972.     -npage                       add page number
  973.     -recursive directory         scan recursively the directory
  974.     -match     files             match different files ex. *.pdf, a?.*
  975.                                  (require -recursive option)
  976.     -border                      border line
  977.     -pdfdir directory            the directory where you want to put the PDFs
  978.     -txtdir directory            the directory where you want to put the texts
  979.     -current                     the program version
  980.     -verbose                     verbose
  981.     -                            use STDIN and STDOUT
  982.  
  983. list:
  984.     with list you can use metacharacters and relative and absolute path name
  985.  
  986. example:
  987.     $producer *.txt
  988.     $producer -m "a*.txt" -r my_directory
  989.  
  990.  
  991. If you want to know more about this tool, you might want
  992. to read the docs. They came together with $producer!
  993.  
  994. Home: $txt2pdfHome
  995.  
  996. USAGEDESC
  997.     exit(1);
  998. }
  999.  
  1000. sub defaultparams {
  1001.     print <<DEFAULTPARAMS;
  1002.  
  1003. tmpdir : ./
  1004. paper : letter
  1005. landscape : 0
  1006. font : Courier
  1007. npage : 0
  1008. lines : 60
  1009. tab : 8
  1010. pointSize : 10
  1011. vertSpace : 12
  1012. typeencoding : default
  1013.  
  1014. DEFAULTPARAMS
  1015.     exit(1);
  1016. }
  1017.  
  1018. exit 0;
  1019.  
  1020. # __END__
  1021.  
  1022. =head1 NAME
  1023.  
  1024. TXT2PDF - Version 5.2 18th September 2001
  1025.  
  1026. =head1 SYNOPSIS
  1027.  
  1028. Syntax : txt2pdf [-options] files
  1029.  
  1030. =head1 DESCRIPTION
  1031.  
  1032. TXT2PDF  is a very flexible and powerful PERL5 program.
  1033. It's a converter from text files to PDF format files.  
  1034.  
  1035. =head1 Features
  1036.  
  1037. TXT2PDF is a native converter,  you don't need to  pass through PostScript
  1038. format.  Some  feature  of TXT2PDF includes :
  1039.  
  1040.  o every   word  like  http://...   ftp://...   mailto:...   https://... 
  1041.    file:...  ldap:... news:...  will become an URL
  1042.  o every word like mime:... will become a link that launch the correct
  1043.    application and opens the file 
  1044.  o you can add page number in every page
  1045.  o you can add text at the beginning and at the end of every file
  1046.  o you can add a border to every page
  1047.  o you can use background and foreground layers
  1048.  o every predefined encodings (WinAnsiEncoding, MacRomanEncoding,
  1049.    MacExpertEncoding) supported inside the PDF format is
  1050.    supported + the Unix default
  1051.  o STDIN and STDOUT support
  1052.  
  1053. =head1 Options
  1054.  
  1055. where options include:
  1056.  
  1057.     -help                        print out this message
  1058.     -default                     print out the default parameters
  1059.     -configure file              default txt2pdf.cfg
  1060.     -landscape
  1061.     -paper format                default letter, valid formats: A3 (or a3),
  1062.                                  A4 (or a4), A5 (or a5), widthxheight
  1063.     -npage                       add page number
  1064.     -recursive directory         scan recursively the directory
  1065.     -match     files             match different files ex. *.pdf, a?.*
  1066.                                  (require -recursive option)
  1067.     -border                      border line
  1068.     -pdfdir directory            the directory where you want to put the PDFs
  1069.     -textdir directory           the directory where you want to put the texts
  1070.     -current                     the program version
  1071.     -verbose                     verbose
  1072.     -                            use STDIN and STDOUT
  1073.  
  1074. list:
  1075.  
  1076.    with list you can use metacharacters and relative and absolute path 
  1077.    name
  1078.  
  1079. -configure  filename:  with this option you can configure an alternate
  1080. configuration file (the default  configuration  file  is  txt2pdf.cfg,
  1081. located  in txt2pdf directory).  This option is very useful if you use
  1082. txt2pdf in a automatic task (e.g.  cron).  e.g.
  1083.  
  1084.   txt2pdf -c c.cfg *.c
  1085.   txt2pdf -m "a*.txt" -r my_directory
  1086.  
  1087. -match files -recursive directory: with  these option  you can convert 
  1088. all the files in the directory and in every its subdirectories
  1089. e.g
  1090. txt2pdf -m "a*.txt" -r .
  1091. to convert  every file  beginning with a and with txt extension to PDF
  1092. inside the . directory and in every its subdirectories 
  1093.  
  1094. Every file of the list is converted in a PDF file.  If the file has an
  1095. extension the extension is changed with .pdf extension,  if  the  file
  1096. doesn't have an extension the .pdf extension is added.
  1097.  
  1098. ASCII 8 chars are converted using ISO Latin1 Encoding
  1099.  
  1100. CreationDate (The date the document was created) in Info dictionary is
  1101. automatically set.
  1102.  
  1103. The   automatic   convertion   of  words  like  http://...   ftp://...
  1104. mailto:...  https://...  file:...  ldap:...  news:...  to URLs.
  1105.  
  1106. =cut
  1107.